<template>
  <div class="reportFormPage">
    <div class="report-dom horizontal">
      <el-row>
        <el-col :span="5" :offset="19">
          <div class="pageNumBox">
            <span>第</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.page }}&nbsp;</span>
            <span>页，共</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.totalPage }}&nbsp;</span>
            <span>页</span>
          </div>
        </el-col>
      </el-row>
      <div class="topTwoBox">
        <div class="centerName">钢材试验检测报告</div>
        <div class="codeText">BGLQ15003F</div>
      </div>
      <div class="threeTopBox">
        <div class="left-border">
          <div class="box-title">检测单位名称：</div>
          <div class>{{ form.jiancdwmc }}</div>
        </div>
        <div class="right-border">
          <span>报告编号：</span>
          <span v-if="isPdf" class="placeholder">{{ form.baogbh }}</span>
          <el-input class="code-input" v-else type="text" v-model="form.baogbh" @focus="handleFocus('baogbh')" />
        </div>
      </div>
      <div class="table-border">
        <!------------------------------表头-------------------------->
        <table height="160px" class="top-table">
          <tbody>
            <tr>
              <td height="30" align="center" width="15%">
                <span style="width: 90px; display: inline-block">施工/委托单位</span>
              </td>
              <td width="35%" bgcolor="#ffffff">
                <span>{{ form.shigwtdw }}</span>
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">工程名称</span>
              </td>
              <td bgcolor="#ffffff" width="35%">
                <span>{{ form.gongcmc }}</span>
              </td>
            </tr>
            <tr>
              <td height="30" align="center" width="15%">
                <span style="width: 90px; display: inline-block">工程部位/用途</span>
              </td>
              <td colspan="3">
                <span>{{ form.gongcbwyt }}</span>
              </td>
            </tr>
            <tr>
              <td height="30" align="center">样品信息</td>
              <td class="specimen-border" colspan="3">
                <span>样品名称：</span>
                <span :class="{ 'placeholder':!form.yangpmc }">{{ form.yangpmc }}</span>
                <span>；样品编号：</span>
                <span :class="{ 'placeholder-long':!form.yangpbh }">{{ form.yangpbh }}</span>
                <span>；样品数量：</span>
                <span :class="{ 'placeholder':!form.yangpsl }">{{ form.yangpsl }}</span>
                <span>；样品状态：</span>
                <span :class="{ 'placeholder':!form.yangpzt }">{{ form.yangpzt }}</span>
                <span>；来样时间：</span>
                <span :class="{ 'placeholder':!form.yangpsj }">{{ form.yangpsj }}</span>
              </td>
            </tr>
            <tr>
              <td height="40" align="center" width="15%">
                <span style="width: 90px; display: inline-block">检测依据</span>
              </td>
              <td width="35%">
                <span v-if="isPdf">{{ form.jiancyj }}</span>
                <el-input v-else type="textarea" v-model="form.jiancyj" :rows="2" class="mark" @dblclick.native="showBsJiancyjView" readonly />
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">判定依据</span>
              </td>
              <td width="35%">
                <span v-if="isPdf">{{ form.pandyj }}</span>
                <el-input v-else type="textarea" v-model="form.pandyj" :rows="2" @dblclick.native="showBsJudgeBaseView" @focus="handleFocus('pandyj')" class="mark" />
              </td>
            </tr>
            <tr class="bottom-border">
              <td height="30" align="center">
                <div>主要仪器设备</div>
                <div>名称及编号</div>
              </td>
              <td colspan="3">
                <span v-if="isPdf">{{ form.zhuyyqsbmcjbh }}</span>
                <el-input v-else type="textarea" :rows="2" v-model="form.zhuyyqsbmcjbh" class="height100 width100 mark" @dblclick.native="showBsInstrumentView" readonly></el-input>
              </td>
            </tr>
          </tbody>
        </table>
        <!------------------------------表中-------------------------->
        <table height="300px" class="middle-table">
          <tbody>
            <tr height="25">
              <td colspan="2">规格牌号</td>
              <td colspan="5"><el-input type="text" v-model="form.guigxh" /></td>
              <td colspan="2">代表数量</td>
              <td colspan="5"><el-input type="text" v-model="form.daibsl" /></td>
              <td colspan="2">取样地点</td>
              <td colspan="4"><el-input type="text" v-model="form.quydd" /></td>
            </tr>
            <tr height="25">
              <td colspan="2">批号</td>
              <td colspan="8"><el-input type="text" v-model="form.pih" /></td>
              <td colspan="2">生产厂家</td>
              <td colspan="8"><el-input type="text" v-model="form.cd" /></td>
            </tr>
            <tr height="40">
              <td rowspan="2">公称直径(mm)</td>
              <td rowspan="2">公称截面积(mm²)</td>
              <td colspan="2">屈服强度(MPa)</td>
              <td colspan="2">抗拉强度(MPa)</td>
              <td colspan="2">断后伸长率(%)</td>
              <td colspan="2">最大力延伸率(%)</td>
              <td colspan="2">强屈比</td>
              <td colspan="2">屈屈比</td>
              <td rowspan="2">断裂特征</td>
              <td>弯曲性能</td>
              <td>反向弯曲性能</td>
              <td colspan="2">重量偏差(%)</td>
              <td rowspan="2">实验结果</td>
            </tr>
            <tr height="40">
              <td>技术指标</td>
              <td>检测结果</td>
              <td>技术指标</td>
              <td>检测结果</td>
              <td>技术指标</td>
              <td>检测结果</td>
              <td>技术指标</td>
              <td>检测结果</td>
              <td>技术指标</td>
              <td>检测结果</td>
              <td>技术指标</td>
              <td>检测结果</td>
              <td>检测结果</td>
              <td>检测结果</td>
              <td>技术指标</td>
              <td>检测结果</td>
            </tr>
            <tr height="25">
              <td width="5%" rowspan="2"><el-input type="text" v-model="form.detailList[0].gongczj" disabled /></td>
              <td width="5%" rowspan="2"><el-input type="text" v-model="form.detailList[0].gongcjmj" disabled /></td>
              <td width="5%" rowspan="2">
                <!-- <el-input type="text" v-model="form.detailList[0].qvfqdjszb" /> -->
                <el-input type="text" v-model="form.detailList[0].qvfqdjszb" class="mark" @dblclick.native="showBsJudgeBaseEditView(0, 1, 'qvfqdjcjg', 0, 1)" readonly />
              </td>
              <td width="5%"><el-input type="text" v-model="form.detailList[0].qvfqdjcjg" disabled /></td>
              <td width="5%" rowspan="2">
                <!-- <el-input type="text" v-model="form.detailList[0].kanglqdjszb" /> -->
                <el-input type="text" v-model="form.detailList[0].kanglqdjszb" class="mark" @dblclick.native="showBsJudgeBaseEditView(2, 3, 'kanglqdjcjg', 0, 1)" readonly />
              </td>
              <td width="5%"><el-input type="text" v-model="form.detailList[0].kanglqdjcjg" disabled /></td>
              <td width="5%" rowspan="2">
                <!-- <el-input type="text" v-model="form.detailList[0].duanhscljszb" /> -->
                <el-input type="text" v-model="form.detailList[0].duanhscljszb" class="mark" @dblclick.native="showBsJudgeBaseEditView(4, 5, 'duanhscljcjg', 0, 1)" readonly />
              </td>
              <td width="5%"><el-input type="text" v-model="form.detailList[0].duanhscljcjg" disabled /></td>
              <td width="5%" rowspan="2">
                <!-- <el-input type="text" v-model="form.detailList[0].zuidlzysljszb" /> -->
                <el-input type="text" v-model="form.detailList[0].zuidlzysljszb" class="mark" @dblclick.native="showBsJudgeBaseEditView(6, 7, 'zuidlzysljcjg', 0, 1)" readonly />
              </td>
              <td width="5%"><el-input type="text" v-model="form.detailList[0].zuidlzysljcjg" disabled /></td>
              <td width="5%" rowspan="2">
                <!-- <el-input type="text" v-model="form.detailList[0].qiangqbjszb" /> -->
                <el-input type="text" v-model="form.detailList[0].qiangqbjszb" class="mark" @dblclick.native="showBsJudgeBaseEditView(8, 9, 'qiangqbjcjg', 0, 1)" readonly />
              </td>
              <td width="5%"><el-input type="text" v-model="form.detailList[0].qiangqbjcjg" disabled /></td>
              <td width="5%" rowspan="2">
                <!-- <el-input type="text" v-model="form.detailList[0].qvqbjszb" /> -->
                <el-input type="text" v-model="form.detailList[0].qvqbjszb" class="mark" @dblclick.native="showBsJudgeBaseEditView(10, 11, 'qvqbjcjg', 0, 1)" readonly />
              </td>
              <td width="5%"><el-input type="text" v-model="form.detailList[0].qvqbjcjg" disabled /></td>
              <td width="5%"><el-input type="text" v-model="form.detailList[0].daunltz" disabled /></td>
              <td width="5%"><el-input type="text" v-model="form.detailList[0].wanqxnjcjg" disabled /></td>
              <td width="5%" rowspan="2"><el-input type="text" v-model="form.detailList[0].fanxwqxnjcjg" disabled /></td>
              <td width="5%" rowspan="2">
                <!-- <el-input type="text" v-model="form.detailList[0].zhonglpcjszb" /> -->
                <el-input type="text" v-model="form.detailList[0].zhonglpcjszb" class="mark" @dblclick.native="showBsJudgeBaseEditView(12, 13, 'zhonglpcjcjg', 0, 1)" readonly />
              </td>
              <td width="5%" rowspan="2"><el-input type="text" v-model="form.detailList[0].zhonglpcjcjg" disabled /></td>
              <td width="5%" rowspan="2"><el-input type="text" v-model="form.detailList[0].shiyjg" disabled /></td>
            </tr>
            <tr height="25">
              <td><el-input type="text" v-model="form.detailList[1].qvfqdjcjg" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[1].kanglqdjcjg" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[1].duanhscljcjg" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[1].zuidlzysljcjg" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[1].qiangqbjcjg" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[1].qvqbjcjg" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[1].daunltz" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[1].wanqxnjcjg" disabled /></td>
            </tr>
            <tr height="25">
              <td rowspan="2"><el-input type="text" v-model="form.detailList[2].gongczj" disabled /></td>
              <td rowspan="2"><el-input type="text" v-model="form.detailList[2].gongcjmj" disabled /></td>
              <td rowspan="2">
                <!-- <el-input type="text" v-model="form.detailList[2].qvfqdjszb" /> -->
                <el-input type="text" v-model="form.detailList[2].qvfqdjszb" class="mark" @dblclick.native="showBsJudgeBaseEditView(14, 15, 'qvfqdjcjg', 2, 3)" readonly />
              </td>
              <td><el-input type="text" v-model="form.detailList[2].qvfqdjcjg" disabled /></td>
              <td rowspan="2">
                <!-- <el-input type="text" v-model="form.detailList[2].kanglqdjszb" /> -->
                <el-input type="text" v-model="form.detailList[2].kanglqdjszb" class="mark" @dblclick.native="showBsJudgeBaseEditView(16, 17, 'kanglqdjcjg', 2, 3)" readonly />
              </td>
              <td><el-input type="text" v-model="form.detailList[2].kanglqdjcjg" disabled /></td>
              <td rowspan="2">
                <!-- <el-input type="text" v-model="form.detailList[2].duanhscljszb" /> -->
                <el-input type="text" v-model="form.detailList[2].duanhscljszb" class="mark" @dblclick.native="showBsJudgeBaseEditView(18, 19, 'duanhscljcjg', 2, 3)" readonly />
              </td>
              <td><el-input type="text" v-model="form.detailList[2].duanhscljcjg" disabled /></td>
              <td rowspan="2">
                <!-- <el-input type="text" v-model="form.detailList[2].zuidlzysljszb" /> -->
                <el-input type="text" v-model="form.detailList[2].zuidlzysljszb" class="mark" @dblclick.native="showBsJudgeBaseEditView(20, 21, 'zuidlzysljcjg', 2, 3)" readonly />
              </td>
              <td><el-input type="text" v-model="form.detailList[2].zuidlzysljcjg" disabled /></td>
              <td rowspan="2">
                <!-- <el-input type="text" v-model="form.detailList[2].qiangqbjszb" /> -->
                <el-input type="text" v-model="form.detailList[2].qiangqbjszb" class="mark" @dblclick.native="showBsJudgeBaseEditView(22, 23, 'qiangqbjcjg', 2, 3)" readonly />
              </td>
              <td><el-input type="text" v-model="form.detailList[2].qiangqbjcjg" disabled /></td>
              <td rowspan="2">
                <!-- <el-input type="text" v-model="form.detailList[2].qvqbjszb" /> -->
                <el-input type="text" v-model="form.detailList[2].qvqbjszb" class="mark" @dblclick.native="showBsJudgeBaseEditView(24, 25, 'qvqbjcjg', 2, 3)" readonly />
              </td>
              <td><el-input type="text" v-model="form.detailList[2].qvqbjcjg" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[2].daunltz" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[2].wanqxnjcjg" disabled /></td>
              <td rowspan="2"><el-input type="text" v-model="form.detailList[2].fanxwqxnjcjg" disabled /></td>
              <td rowspan="2">
                <!-- <el-input type="text" v-model="form.detailList[2].zhonglpcjszb" /> -->
                <el-input type="text" v-model="form.detailList[2].zhonglpcjszb" class="mark" @dblclick.native="showBsJudgeBaseEditView(26, 27, 'zhonglpcjcjg', 2, 3)" readonly />
              </td>
              <td rowspan="2"><el-input type="text" v-model="form.detailList[2].zhonglpcjcjg" disabled /></td>
              <td rowspan="2"><el-input type="text" v-model="form.detailList[2].shiyjg" disabled /></td>
            </tr>
            <tr height="25">
              <td><el-input type="text" v-model="form.detailList[3].qvfqdjcjg" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[3].kanglqdjcjg" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[3].duanhscljcjg" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[3].zuidlzysljcjg" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[3].qiangqbjcjg" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[3].qvqbjcjg" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[3].daunltz" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[3].wanqxnjcjg" disabled /></td>
            </tr>
            <tr height="25">
              <td rowspan="2"><el-input type="text" v-model="form.detailList[4].gongczj" disabled /></td>
              <td rowspan="2"><el-input type="text" v-model="form.detailList[4].gongcjmj" disabled /></td>
              <td rowspan="2">
                <!-- <el-input type="text" v-model="form.detailList[4].qvfqdjszb" /> -->
                <el-input type="text" v-model="form.detailList[4].qvfqdjszb" class="mark" @dblclick.native="showBsJudgeBaseEditView(28, 29, 'qvfqdjcjg', 4, 5)" readonly />
              </td>
              <td><el-input type="text" v-model="form.detailList[4].qvfqdjcjg" disabled /></td>
              <td rowspan="2">
                <!-- <el-input type="text" v-model="form.detailList[4].kanglqdjszb" /> -->
                <el-input type="text" v-model="form.detailList[4].kanglqdjszb" class="mark" @dblclick.native="showBsJudgeBaseEditView(30, 31, 'kanglqdjszb', 4, 5)" readonly />
              </td>
              <td><el-input type="text" v-model="form.detailList[4].kanglqdjcjg" disabled /></td>
              <td rowspan="2">
                <!-- <el-input type="text" v-model="form.detailList[4].duanhscljszb" /> -->
                <el-input type="text" v-model="form.detailList[4].duanhscljszb" class="mark" @dblclick.native="showBsJudgeBaseEditView(32, 33, 'duanhscljcjg', 4, 5)" readonly />
              </td>
              <td><el-input type="text" v-model="form.detailList[4].duanhscljcjg" disabled /></td>
              <td rowspan="2">
                <!-- <el-input type="text" v-model="form.detailList[4].zuidlzysljszb" /> -->
                <el-input type="text" v-model="form.detailList[4].zuidlzysljszb" class="mark" @dblclick.native="showBsJudgeBaseEditView(34, 35, 'zuidlzysljcjg', 4, 5)" readonly />
              </td>
              <td><el-input type="text" v-model="form.detailList[4].zuidlzysljcjg" disabled /></td>
              <td rowspan="2">
                <!-- <el-input type="text" v-model="form.detailList[4].qiangqbjszb" /> -->
                <el-input type="text" v-model="form.detailList[4].qiangqbjszb" class="mark" @dblclick.native="showBsJudgeBaseEditView(36, 37, 'qiangqbjcjg', 4, 5)" readonly />
              </td>
              <td><el-input type="text" v-model="form.detailList[4].qiangqbjcjg" disabled /></td>
              <td rowspan="2">
                <!-- <el-input type="text" v-model="form.detailList[4].qvqbjszb" /> -->
                <el-input type="text" v-model="form.detailList[4].qvqbjszb" class="mark" @dblclick.native="showBsJudgeBaseEditView(38, 39, 'qvqbjcjg', 4, 5)" readonly />
              </td>
              <td><el-input type="text" v-model="form.detailList[4].qvqbjcjg" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[4].daunltz" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[4].wanqxnjcjg" disabled /></td>
              <td rowspan="2"><el-input type="text" v-model="form.detailList[4].fanxwqxnjcjg" disabled /></td>
              <td rowspan="2">
                <!-- <el-input type="text" v-model="form.detailList[4].zhonglpcjszb" /> -->
                <el-input type="text" v-model="form.detailList[4].zhonglpcjszb" class="mark" @dblclick.native="showBsJudgeBaseEditView(40, 41, 'zhonglpcjcjg', 4, 5)" readonly />
              </td>
              <td rowspan="2"><el-input type="text" v-model="form.detailList[4].zhonglpcjcjg" disabled /></td>
              <td rowspan="2"><el-input type="text" v-model="form.detailList[4].shiyjg" disabled /></td>
            </tr>
            <tr height="25">
              <td><el-input type="text" v-model="form.detailList[5].qvfqdjcjg" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[5].kanglqdjcjg" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[5].duanhscljcjg" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[5].zuidlzysljcjg" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[5].qiangqbjcjg" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[5].qvqbjcjg" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[5].daunltz" disabled /></td>
              <td><el-input type="text" v-model="form.detailList[5].wanqxnjcjg" disabled /></td>
            </tr>
            <tr>
              <td colspan="20" height="30px">
                <span v-if="isPdf" class="textarea-span">{{ form.jiancjl }}</span>
                <el-input v-else type="textarea" :rows="2" v-model="form.jiancjl" @focus="handleFocus('jiancjl')" @dblclick.native="getJcjl()" />
              </td>
            </tr>
          </tbody>
        </table>
        <!------------------------------附加声明-------------------------->
        <table height="30px" class="bottom-table">
          <tr>
            <td>
              <span v-if="isPdf" class="textarea-span">{{ form.fujsm }}</span>
              <el-input v-else type="textarea" :rows="2" v-model="form.fujsm" @focus="handleFocus('fujsm')" />
            </td>
          </tr>
        </table>
      </div>
      <!------------------------------表底-------------------------->
      <table height="22px" class="transparent">
        <tbody>
        <tr>
          <td width="10%" align="right">检测：</td>
          <td width="15%" align="left"></td>
          <td width="10%" align="right">审核：</td>
          <td width="15%" align="left"></td>
          <td width="10%" align="right">批准：</td>
          <td align="left" width="15%"></td>
          <td width="10%">日期：</td>
          <td align="left" width="15%"></td>
        </tr>
        </tbody>
      </table>
    </div>
    <bs-instrument-view ref="bsInstrumentViewRef" @select="selectInstrument"></bs-instrument-view>
    <bs-jiancyj-view ref="bsJiancyjViewRef" @select="selectJiancyj" :syType="syType"></bs-jiancyj-view>
    <bs-judge-base-view ref="bsJudgeBaseViewRef" @select="selectJudge" :syType="syType"></bs-judge-base-view>
    <bs-judge-base-edit-view ref="bsJudgeBaseEditViewRef" @submit="selectJudgeBaseEdit" :syType="syType"></bs-judge-base-edit-view>
  </div>
</template>

<script>
import { listGcsyjcbgBsInfo, getGcsyjcbgBsInfo, delGcsyjcbgBsInfo, addGcsyjcbgBsInfo, updateGcsyjcbgBsInfo, queryJcjl } from "@/api/report_gc/gcsyjcbgBsInfo";
import BsInstrumentView from "@/views/dept/bsInstrument/BsInstrumentView.vue";
import decimal from "@/utils/big-decimal";
import BsJiancyjView from "@/views/sycs/bsJiancyj/BsJiancyjView";
import BsJudgeBaseView from "@/views/sycs/bsJudgeBase/BsJudgeBaseView";
import Bus from "@/utils/bus";
import { emptyConvert, handleFocus, uniqueStr } from "@/views/reportForms/utils";
import { computeBiQualification } from "@/api/sycs/biQualification";
import BsJudgeBaseEditView from "@/views/sycs/bsJudgeBase/BsJudgeBaseEditView.vue";

export default {
  name: "gcsyjcbg",
  components: {
    BsInstrumentView,
    BsJiancyjView,
    BsJudgeBaseView,
    BsJudgeBaseEditView
  },
  props: {
    excelId: {
      type: [String, Number],
      default: () => ""
    },
    syType: {
      type: [String, Number],
      default: () => ""
    },
    page: {
      type: Number,
      default: () => 0
    },
    isPdf: {
      type: Boolean,
      default: () => false
    }
  },
  data() {
    return {
      activeKey1: null,
      activeKey2: null,
      keyName: null,
      id2: null,
      rowIndex1: null,
      rowIndex2: null,
      params: {},
      query: {},
      // 表单参数
      form: {
        detailList: [{}, {}, {}, {}, {}, {}],
        baDetailVos: [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]
      },
      // 表单校验
      rules: {
        excelId: [{ required: true, message: "主键不能为空", trigger: "blur" }]
      }
    };
  },
  watch: {
    isPdf(newVal, oldVal) {
      this.form = { ...emptyConvert(this.form, newVal) };
    }
  },

  created() {
    this.getInfo();
  },
  mounted() {
    Bus.$on("setGcQfKlForm", (data) => {
      for (let i = 0; i <= 4; i++) {
        if (i % 2 === 0) {
          this.form.detailList[i].gongczj = data.detailList[i].gongczj;
          this.form.detailList[i].gongcjmj = data.detailList[i].gongcjmj;
        }
      }
      for (let i = 0; i <= 5; i++) {
        this.form.detailList[i].qvfqdjcjg = data.detailList[i].qvfqd;
        this.form.detailList[i].kanglqdjcjg = data.detailList[i].kanglqd;
        this.form.detailList[i].duanhscljcjg = data.detailList[i].duanhscl;
        this.form.detailList[i].zuidlzysljcjg = data.detailList[i].zuidlzysl;
        this.form.detailList[i].qiangqbjcjg = data.detailList[i].qiangqb;
        this.form.detailList[i].qvqbjcjg = data.detailList[i].qvqb;
        this.form.detailList[i].daunltz = data.detailList[i].daunltz;
      }
    });
    // 重量偏差(%)
    Bus.$on("setGcSyZhonglpcForm", (data) => {
      const keys = Object.keys(data);
      let name = keys[0];
      this.form.detailList[name].zhonglpcjcjg = data[name];
    });
    // 反向弯曲性能
    Bus.$on("setGcFxwqXN", (data) => {
      const keys = Object.keys(data);
      let name = keys[0];
      this.form.detailList[name].fanxwqxnjcjg = data[name];
    });
    // 弯曲性能
    Bus.$on("setGcWqxn", (data) => {
      const keys = Object.keys(data);
      let name = keys[0];
      this.form.detailList[name].wanqxnjcjg = data[name];
    });

    // 检测依据
    Bus.$on("setGcsyjcBgJiancyj", (data) => {
      const { jiancyj, jiancyjIds } = data;
      const str = jiancyj + (this.form.jiancyj ? "、" + this.form.jiancyj : "");
      const ids = jiancyjIds + (this.form.jiancyjIds ? "," + this.form.jiancyjIds : "");
      this.form.jiancyj = uniqueStr(str, "、");
      this.form.jiancyjIds = uniqueStr(ids, ",");
    });
    // 主要设备
    Bus.$on("setGcsyjcBgZhuyyqsbmcjbh", (data) => {
      const { zhuyyqsbmcjbh, shebIds } = data;
      const str = zhuyyqsbmcjbh + (this.form.zhuyyqsbmcjbh ? "、" + this.form.zhuyyqsbmcjbh : "");
      const ids = shebIds + (this.form.shebIds ? "," + this.form.shebIds : "");
      this.form.zhuyyqsbmcjbh = uniqueStr(str, "、");
      this.form.shebIds = uniqueStr(ids, ",");
    });
  },
  beforeDestroy() {
    // 或者你可以使用其他合适的生命周期钩子
    // 停止监听事件
    Bus.$off("setGcFxwqXN");
    Bus.$off("setGcWqxn");
    Bus.$off("setGcQfKlForm");
    Bus.$off("setGcSyZhonglpcForm");
    Bus.$off("setGcsyjcBgJiancyj");
    Bus.$off("setGcsyjcBgZhuyyqsbmcjbh");
  },
  methods: {
    // 获取详情
    getInfo() {
      if (!this.excelId) {
        return;
      }
      console.error(this.excelId || this.$defaultExcelId);
      getGcsyjcbgBsInfo(this.excelId || this.$defaultExcelId).then((response) => {
        this.form = response.data;
        if (!this.form.jiancjl) {
          this.form.jiancjl = "检测结论：";
        }
        if (!this.form.fujsm) {
          this.form.fujsm = "附加声明：";
        }
      });
    },

    // 显示检测依据列表
    showBsJiancyjView() {
      this.$refs.bsJiancyjViewRef.init(this.form.jiancyjIds);
    },
    // 检测依据选择
    selectJiancyj(info) {
      this.form.jiancyj = info.label;
      this.form.jiancyjIds = info.ids;
    },

    // 显示判定依据列表
    showBsJudgeBaseView() {
      this.$refs.bsJudgeBaseViewRef.init(this.form.pandyjIds);
    },
    // 判断依据选择
    selectJudge(info) {
       this.form.pandyjIds = info.ids;
      this.form.pandyj = info.label;
    },

    // 显示仪器列表
    showBsInstrumentView() {
      this.$refs.bsInstrumentViewRef.init(this.form.shebIds);
    },
    // 仪器选择
    selectInstrument(info) {
      this.form.zhuyyqsbmcjbh = info.label;
      this.form.shebIds = info.ids;
    },

    // 获取检测结论
    getJcjl() {
      const form = JSON.parse(JSON.stringify(this.form));
      queryJcjl(emptyConvert(form)).then((res) => {
        const info = res.data;
        this.form.jiancjl = info.jiancjl;
      });
    },
    handleFocus(event) {
      handleFocus(event, this.page, this.form[event]);
    },
    // 显示单个技术编辑
    showBsJudgeBaseEditView(key1, key2, name, rowIndex1, rowIndex2) {
      this.activeKey1 = key1;
      this.activeKey2 = key2;
      this.keyName = name;
      this.rowIndex1 = rowIndex1;
      this.rowIndex2 = rowIndex2;
      const info1 = this.form.baDetailVos[key1];
      const info2 = this.form.baDetailVos[key2];
      this.id2 = this.form.baDetailVos[key2].id;
      info1.refQualId = info1.qualId;
      info2.refQualId = info2.qualId;
      this.$refs.bsJudgeBaseEditViewRef.init(info1);
    },
    // 编辑单个技术指标后赋值
    selectJudgeBaseEdit(info) {
      if (info.qualId) {
        this.form.baDetailVos[this.activeKey1] = { ...info, rowIndex: this.rowIndex1 };
        this.form.baDetailVos[this.activeKey2] = { ...info, id: this.id2, rowIndex: this.rowIndex2 };
      }
      this.computeDetectionResult([this.activeKey1, this.activeKey2]);
    },
    // 计算检测结果
    computeDetectionResult(keys) {
      if (!keys || keys.length <= 0) {
        return;
      }

      let data = keys.map((key) => {
        const info = {
          ...this.form.baDetailVos[key]
        };
        return info;
      });

      data.forEach((v) => {
        // console.log(this.form.detailList[v.rowIndex][this.keyName]);
        v.jiancjg = this.form.detailList[v.rowIndex][this.keyName];
      });

      computeBiQualification(data).then((res) => {
        let name = this.keyName.substring(0, this.keyName.length - 4) + "jszb";
        const returnData = res.data;
        returnData.forEach((item) => {
          item.jiancjg = item.jiancjg ? item.jiancjg : "-";
          // 技术指标赋值
          this.form.detailList[this.rowIndex1][name] = item.jiszb;
        });

        this.form.baDetailVos[this.activeKey1] = res.data[0];
        this.form.baDetailVos[this.activeKey2] = res.data[1];
        this.determineIsTF();
      });
      // 判断实验结果符合不符合
    },
    determineIsTF() {
      var row1 = this.form.baDetailVos.slice(0, 14);
      var row2 = this.form.baDetailVos.slice(14, 28);
      var row3 = this.form.baDetailVos.slice(28, 42);
      let result1 = row1.some((e) => e.jiegpd === "不符合");
      let result2 = row2.some((e) => e.jiegpd === "不符合");
      let result3 = row3.some((e) => e.jiegpd === "不符合");

      if (result1 && this.rowIndex1 == 0) {
        this.form.detailList[0].shiyjg = "不符合";
      } else if (result2 && this.rowIndex1 == 2) {
        this.form.detailList[2].shiyjg = "不符合";
      } else if (result3 && this.rowIndex1 == 4) {
        this.form.detailList[4].shiyjg = "不符合";
      } else {
        this.form.baDetailVos[this.activeKey1].jiegpd == "符合" ? "符合" : "-";
        this.form.detailList[this.rowIndex1]["shiyjg"] = this.form.baDetailVos[this.activeKey1].jiegpd;
      }
    },
    submitForm () {
      return this.form;
    },
  }
};
</script>


<style scoped>
</style>
